
#include "member_BHandler.h"

using namespace BWE;

member_BHandler::member_BHandler(BHandler* handler)
{
	boss = handler;
	viewer = 0;
	parent = 0;
}
member_BHandler::~member_BHandler()
{

}

void member_BHandler::setViewer(BViewer* newViewer)
{
	if (viewer != newViewer)
	{
		if (viewer)
		{
			boss->detached(viewer);
			boss->emit(Signal_Detached, BValue(viewer, true));
		}
		viewer = newViewer;
		if (viewer)
		{
			boss->attached(viewer);
			boss->emit(Signal_Attached, BValue(viewer, true));
		}
		for (int i = 0; i < children.size(); i++)
		{
			BHandler* child = children[i];
			handler_member(child)->setViewer(viewer);
		}
	}
}
